﻿using System.Windows;
using System.ComponentModel;
using System.Windows.Media.Animation;

namespace SurveySez.View
{
	/// <summary>
	/// Interaction logic for Window1.xaml
	/// </summary>
	public partial class PublicWindow : Window
	{
		public PublicWindow()
		{
			InitializeComponent();

			DataContextChanged += (sender, e) => SubscribeForPropertyChanged();
			SubscribeForPropertyChanged();
		}


		private void SubscribeForPropertyChanged()
		{
			INotifyPropertyChanged dataContext = DataContext as INotifyPropertyChanged;
			if (dataContext != null)
				dataContext.PropertyChanged += new PropertyChangedEventHandler(dataContext_PropertyChanged);
		}

		void dataContext_PropertyChanged(object sender, PropertyChangedEventArgs e)
		{
			if (e.PropertyName == "IncorrectGuesses")
			{
				BeginStoryboard((Storyboard)Resources["FadeOut"]);
			}
		}
	}
}
